package com.econ.powercloud.ems.common.enums;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author jwc
 * @date 2022/11/11
 */
public enum ModulePositionEnum implements EnumMethod {
    CONTAINER_TO_CLUSTER(1, "集装箱下的簇的数据",CategoryEnum.BATTERY_MONITOR),
    CLUSTER_RELATION_PID(2,"电池监控-电池簇-点号配置数据",CategoryEnum.BATTERY_MONITOR),

    OVERVIEW_STATUS(3, "高级策略投入状态", CategoryEnum.OVERVIEW),
    OVERVIEW_CHART(4, "高级策略动作情况图", CategoryEnum.OVERVIEW),
    AGC_CONTROL(5, "AGC控制", CategoryEnum.AGC,true),
    AGC_STAT_DATA(6, "AGC统计数据", CategoryEnum.AGC),
    AGC_RUN_DATA(7, "AGC实测数据", CategoryEnum.AGC),
    AGC_STATUS(8, "AGC状态", CategoryEnum.AGC),
    AGC_CONSTANT_SET(9, "AGC常量设定", CategoryEnum.AGC),
    AGC_CHART(10, "AGC折线图", CategoryEnum.AGC),
    AGC_HISTORY(11, "AGC历史指令", CategoryEnum.AGC),
    AVC_CONTROL(12, "AVC控制", CategoryEnum.AVC,true),
    AVC_STAT_DATA(13, "AVC统计数据", CategoryEnum.AVC),
    AVC_RUN_DATA(14, "AVC实测数据", CategoryEnum.AVC),
    AVC_STATUS(15, "AVC状态", CategoryEnum.AVC),
    AVC_CONSTANT_SET(16, "AVC常量设定", CategoryEnum.AVC),
    AVC_CHART(17, "AVC折线图", CategoryEnum.AVC),
    AVC_HISTORY(18, "AVC历史指令", CategoryEnum.AVC),
    PRIMARY_FREQUENCY_CONTROL(19, "一次调频-控制", CategoryEnum.PRIMARY_FREQUENCY_CONTROL,true),
    PRIMARY_FREQUENCY_STAT_DATA(20, "一次调频-统计数据", CategoryEnum.PRIMARY_FREQUENCY_CONTROL),
    PRIMARY_FREQUENCY_RUN_DATA(21, "一次调频-实测数据", CategoryEnum.PRIMARY_FREQUENCY_CONTROL),
    PRIMARY_FREQUENCY_STATUS(22, "一次调频-状态", CategoryEnum.PRIMARY_FREQUENCY_CONTROL),
    PRIMARY_FREQUENCY_CONSTANT_SET(23, "一次调频-常量设定", CategoryEnum.PRIMARY_FREQUENCY_CONTROL),
    PRIMARY_FREQUENCY_CHART(24, "一次调频-并网点频率曲线图", CategoryEnum.PRIMARY_FREQUENCY_CONTROL),
    PRIMARY_FREQUENCY_POWER_CHART(25, "一次调频-全站有功功率图", CategoryEnum.PRIMARY_FREQUENCY_CONTROL),
    PRIMARY_FREQUENCY_HISTORY(26, "一次调频-历史指令", CategoryEnum.PRIMARY_FREQUENCY_CONTROL),
    REACTIVE_POWER_CONTROL(27, "动态无功调压-控制", CategoryEnum.REACTIVE_POWER,true),
    REACTIVE_POWER_STAT_DATA(28, "动态无功调压-统计数据", CategoryEnum.REACTIVE_POWER),
    REACTIVE_POWER_RUN_DATA(29, "动态无功调压-实测数据", CategoryEnum.REACTIVE_POWER),
    REACTIVE_POWER_STATUS(30, "动态无功调压-状态", CategoryEnum.REACTIVE_POWER),
    REACTIVE_POWER_CONSTANT_SET(31, "动态无功调压-常量设定", CategoryEnum.REACTIVE_POWER),
    REACTIVE_POWER_CHART(32, "动态无功调压-折线图", CategoryEnum.REACTIVE_POWER),
    REACTIVE_POWER_HISTORY(33, "动态无功调压-历史指令", CategoryEnum.REACTIVE_POWER),
    PRECISE_CUT_CONTROL(34, "精准切负荷-控制", CategoryEnum.PRECISE_CUT,true),
    PRECISE_CUT_STAT_DATA(35, "精准切负荷-统计数据", CategoryEnum.PRECISE_CUT),
    PRECISE_CUT_RUN_DATA(36, "精准切负荷-实测数据", CategoryEnum.PRECISE_CUT),
    PRECISE_CUT_STATUS(37, "精准切负荷-状态", CategoryEnum.PRECISE_CUT),
    PRECISE_CUT_CONSTANT_SET(38, "精准切负荷-常量设定", CategoryEnum.PRECISE_CUT),
    PRECISE_CUT_CHART(39, "精准切负荷-折线图", CategoryEnum.PRECISE_CUT),
    PRECISE_CUT_HISTORY(40, "精准切负荷-历史指令", CategoryEnum.PRECISE_CUT),
    CHARGE_PLAN_CHART(41, "充放电计划-全站有功功率折线图", CategoryEnum.CHARGE_PLAN),
    CHARGE_PLAN_CONTROL(48, "充放电计划-控制", CategoryEnum.CHARGE_PLAN,true),
    SMOOTH_STAT_DATA(42, "平滑出力-统计数据", CategoryEnum.SMOOTH),
    SMOOTH_RUN_DATA(43, "平滑出力-实测数据", CategoryEnum.SMOOTH),
    SMOOTH_STATUS(44, "平滑出力-状态", CategoryEnum.SMOOTH),
    SMOOTH_CONSTANT_SET(45, "平滑出力-常量设定", CategoryEnum.SMOOTH),
    SMOOTH_CHART(46, "平滑出力-折线图", CategoryEnum.SMOOTH),
    SMOOTH_CONTROL(47, "平滑出力-控制", CategoryEnum.SMOOTH,true),
    ECON_MODEL_CONTROL(49,"经济模式-控制",CategoryEnum.ECON_MODEL,true),
    OVERVIEW_MONITOR(50, "总览-全站监控", CategoryEnum.OVERVIEW),
    RUN_MONITOR(51,"实时监控",CategoryEnum.DEVICE_MONITOR),
    STATION_SUM_POWER(52,"全站总功率曲线",CategoryEnum.DEVICE_MONITOR),
    STATION_CHARGE_DISCHARGE(53,"全站充放电量",CategoryEnum.DEVICE_MONITOR),
    STATION_POWER_CONSUMPTION(54,"全站用电量",CategoryEnum.DEVICE_MONITOR),
    AGC_I(60, "AGC远方/就地", CategoryEnum.AGC,true),
    AVC_I(61, "AVC远方/就地", CategoryEnum.AVC,true),
    ;

    private Integer code;
    private String desc;
    private CategoryEnum categoryEnum;
    /** 是否是控制类型的位置 */
    private boolean controlType;

    ModulePositionEnum(Integer code, String desc, CategoryEnum categoryEnum) {
        this.code = code;
        this.desc = desc;
        this.categoryEnum = categoryEnum;
    }

    ModulePositionEnum(Integer code, String desc, CategoryEnum categoryEnum,boolean controlType) {
        this.code = code;
        this.desc = desc;
        this.categoryEnum = categoryEnum;
        this.controlType = controlType;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public boolean getControlType() {
        return controlType;
    }

    public CategoryEnum getCategoryEnum() {
        return categoryEnum;
    }

    public static ModulePositionEnum fromCode(Integer code) {
        for (ModulePositionEnum obj : ModulePositionEnum.values()) {
            if (code.equals(obj.getCode())) {
                return obj;
            }
        }
        return OVERVIEW_STATUS;
    }

    public static String getDescFromCode(int code){
        for(ModulePositionEnum e: ModulePositionEnum.values()){
            if(e.getCode() == code){
                return e.getDesc();
            }
        }
        return "";
    }

    public static List<ModulePositionEnum> fromCategoryEnums(List<CategoryEnum> categoryEnumList){
        List<ModulePositionEnum> result = Lists.newArrayList();
        for (ModulePositionEnum obj : ModulePositionEnum.values()) {
            if (categoryEnumList.contains(obj.getCategoryEnum())) {
                result.add(obj);
            }
        }
        return result;
    }

}
